import UserAPI from "@/api/order";
import type { UserQuery } from "@/api/user/model";
import type { IContentConfig } from "@/components/PageContent/index.vue";

const contentConfig: IContentConfig<UserQuery> = {
  pageName: "sys:user",
  table: {
    border: true,
    highlightCurrentRow: true,
  },
  indexAction: function (params) {
    if ("createAt" in params) {
      const createAt = params.createAt as string[];
      params.startTime = createAt[0];
      params.endTime = createAt[1];
      delete params.createAt;
    }
    return UserAPI.getPage(params);
  },
  deleteAction: UserAPI.deleteByIds,
  exportAction: UserAPI.export,
  pk: "id",
  toolbar: [
    // "add",
    "delete",
    "export",
    // {
    //   name: "import",
    //   icon: "upload",
    //   text: "导入",
    //   auth: "import",
    // },
  ],
  cols: [
    { type: "selection", width: 50, align: "center" },
    { label: "订单编号", align: "center", prop: "orderNo", minWidth: 120 },
    { label: "下单地址", align: "center", prop: "address", minWidth: 180 },
    { label: "服务名称", align: "center", prop: "serviceTitle", minWidth: 120 },
    { label: "金额", align: "center", prop: "amount", minWidth: 100 },
    { label: "优惠金额", align: "center", prop: "discountAmount", minWidth: 100 },
    { label: "预约时间", align: "center", prop: "appointmentDate", minWidth: 180 },
    { label: "订单状态", align: "center", prop: "status", slotName: "status", templet: "custom", minWidth: 100, },
    { label: "下单时间", align: "center", prop: "createTime", minWidth: 180 },
    {
      label: "操作",
      fixed: "right",
      minWidth: 220,
      templet: "tool",
      align: "center",
      operat: [
        {
          name: "dispatch",
          auth: "password:reset",
          text: "订单派单",
        },
        {
          name: "complete",
          auth: "password:reset",
          text: "完成订单",
        },
        "delete",
      ],
    },
  ],
};

export default contentConfig;
